package main

import "fmt"

type student struct {
	id    int
	name  string
	class string
}

//student的构造函数
func newStu(id int, name string, class string) *student {
	return &student{
		id:    id,
		name:  name,
		class: class,
	}
}

type stuMgr struct {
	allStu []*student
}

func newStuMgr() *stuMgr {
	return &stuMgr{
		allStu: make([]*student, 0, 100),
	}
}

func (s *stuMgr) add(stu *student) {
	s.allStu = append(s.allStu, stu)
}

func (s *stuMgr) edit(stu *student) {
	for i, v := range s.allStu {
		if stu.id == v.id {
			s.allStu[i] = stu
			return
		}
	}
	fmt.Println("该学生信息不存在")
}

func (s *stuMgr) show() {

	for _, v := range s.allStu {
		fmt.Printf("学号: %d 姓名: %s 班级: %s", v.id, v.name, v.class)
	}
}
